#! /usr/bin/env python3
import sys


class Cmd:
    helpFlag = False
    versionFlag = False
    cpOption = ''
    className = ''
    xJreOption = ''
    args = []


def parseCmd():

    # print('参数个数为', len(sys.argv), '个参数')
    # print('参数列表', str(sys.argv))
    cmd = Cmd()
    lastValue = ''
    cmdMap = {}
    args = []
    for i in sys.argv:
        if i.startswith('-'):
            key = i[1:]
            cmdMap.update({key: ''})
        else:
            if lastValue.startswith('-'):
                key = i[1:]
                cmdMap[key] = i
            else:
                args.append(i)
        lastValue = i
    # print(cmdMap)
    # print(args)
    if 'help' in cmdMap or '?' in cmdMap:
        cmd.helpFlag = True
    if 'version' in cmdMap:
        cmd.versionFlag = True
    if 'classpath' in cmdMap:
        cmd.cpOption = cmdMap.get('classpath')
    if 'cp' in cmdMap:
        cmd.cpOption = cmdMap.get('cp')
    if 'Xjre' in cmdMap:
        cmd.xJreOption = cmdMap.get('Xjre')
    if len(args) > 1:
        cmd.className = args[1]
        cmd.args = args[2:]
    # print(cmd.helpFlag)
    # print(cmd.versionFlag)
    # print(cmd.cpOption)
    # print(cmd.className)
    # print(cmd.args)
    return cmd


def printUsage():
	print("Usage :%s [-options] class [args...]\n" %sys.argv[0])

